﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Content/Master.Master" ValidateRequest="false" Inherits="System.Web.Mvc.ViewPage<SCS.Core.Models.Collection.ArticleStaticCollection>" %>
<%@ Import Namespace="SCS.Core" %>
<%@ Import Namespace="SCS.Core.Models" %>
<%@ Import Namespace="SCS.Core.ViewModels" %>
<%@ Import Namespace="SCS.Core.Controllers" %>
<%@ Import Namespace="SCSService" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Nội dung chi tiết
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <!--Editor-->
    <link rel="stylesheet" href="/Editor/themes/default/default.css" />
	<link rel="stylesheet" href="/Editor/plugins/code/prettify.css" />
	<script type="text/javascript" charset="utf-8" src="/Editor/kindeditor.js"></script>
	<script type="text/javascript" charset="utf-8" src="/Editor/lang/en_US.js"></script>
	<script type="text/javascript" charset="utf-8" src="/Editor/plugins/code/prettify.js"></script>
	<script type="text/javascript">
	    KindEditor.ready(function (K) {
	        var editor1 = K.create('#StaticIntroText', {
	            cssPath: '/Editor/plugins/code/prettify.css',
	            uploadJson: '/Editor/aspnet/upload_json.ashx',
	            fileManagerJson: '/Editor/aspnet/file_manager_json.ashx',
	            allowFileManager: true,
	            afterCreate: function () {
	                var self = this;
	                K.ctrl(document, 13, function () {
	                    self.sync();
	                    K('form[name=example]')[0].submit();
	                });
	                K.ctrl(self.edit.doc, 13, function () {
	                    self.sync();
	                    K('form[name=example]')[0].submit();
	                });
	            }

	        });
	        prettyPrint();
	    });
	</script>
    <script type="text/javascript">
        KindEditor.ready(function (K) {
            var editor2 = K.create('#StaticContent', {
                cssPath: '/Editor/plugins/code/prettify.css',
                uploadJson: '/Editor/aspnet/upload_json.ashx',
                fileManagerJson: '/Editor/aspnet/file_manager_json.ashx',
                allowFileManager: true,
                afterCreate: function () {
                    var self = this;
                    K.ctrl(document, 13, function () {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                    K.ctrl(self.edit.doc, 13, function () {
                        self.sync();
                        K('form[name=example]')[0].submit();
                    });
                }

            });
            prettyPrint();
        });
	</script>
    <!--End Editor-->

    <script type="text/javascript" src="/ThemeExtends/AdminSkin/js/jquery.flot.js"></script>
    <script type="text/javascript" src="/ThemeExtends/AdminSkin/js/jquery.flot.stack.js"></script>	
    <link rel="stylesheet" type="text/css" href="/Content/smoothness-1.8.13/jquery-ui-1.8.13.custom.css"/>
    <link rel="stylesheet" type="text/css" href="/Content/smoothness-1.8.13/ui.dropdownchecklist.themeroller.css"/>
    <script type="text/javascript" src="/Scripts/jquery-1.6.1.min.js"></script>
    <script type="text/javascript" src="/Scripts/jquery-ui-1.8.13.custom.min.js"></script>
    <script type="text/javascript" src="/Scripts/ui.dropdownchecklist-1.4-min.js"></script>
    <script type="text/javascript" src="/Scripts/ui.dropdownchecklist.js"></script>
    <%--Validator--%>
    <script src="/Scripts/jquery.validate.min.js" type="text/javascript"></script>
    <script src="/Scripts/MicrosoftMvcJQueryValidation.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $("#CategoriesID").dropdownchecklist({ icon: {}, width: 350, firstItemChecksAll: false, explicitClose: '...X', forceMultiple: true
            , onComplete: function (selector) {
                var values = "";
                for (i = 0; i < selector.options.length; i++) {
                    if (selector.options[i].selected && (selector.options[i].value != "")) {
                        if (values != "") values += ",";
                        values += selector.options[i].value;
                    }
                }

                if (document.all || document.getElementById)
                    document.getElementById('ArrayArticleStaticCategoryID').value = values;
                else
                    document.getElementById('ArrayArticleStaticCategoryID').setAttribute("value", values);

            }
            , onItemClick: function (checkbox, selector) {
                var justChecked = checkbox.prop("checked");
                var checkCount = (justChecked) ? 1 : -1;
                for (i = 0; i < selector.options.length; i++) {
                    if (selector.options[i].selected) checkCount += 1;
                }
            }
            });



        });
    </script>

    <% Html.EnableClientValidation(); %>
    <% using (Html.BeginForm((bool)ViewData["IsAdd"] ? "SaveAddArticleStatic" : "SaveEditArticleStatic", "ArticaleMaster", FormMethod.Post, new { siteGuid = "sendFileForm", language = "sendFileForm", id = "sendFileForm", enctype = "multipart/form-data" }))
            {%>
     
     <div class="clear"></div>
       
        <div class="box ">
		    <h2 class="box-header"><%=(bool)ViewData["IsAdd"] ? "Thêm mới nội dung" : "Cập nhật nội dung" %></h2>
		    <div class="box-content">

                <label class="form-label"> Article Static Name </label>
                <%= Html.TextBoxFor(m => m.StaticName, new { @class = "form-field width30" })%> 
                
                 <%--<label class="form-label"> Categories Alias </label>
                 <%= Html.TextBoxFor(m => m.Alias, new { @class = "form-field width30" })%>--%> 
                 <%=Html.HiddenFor(m=>m.Alias) %>
                   <br /><br />
                 <label class="form-label"> Đường dẫn nguồn </label>
                 <%= Html.TextBoxFor(m => m.Url, new { @class = "form-field half" })%>
                 <%if (Model.Url != null)
                  {
                      string src = Model.Url;
                       
                           %>
                            
                               <input type="button" onclick="window.open('/Editor/aspnet/Documents.aspx','images',' width=750,height=450,left=150,top=200,toolbar=no,status=0,scrollbars=1,location=0,');" name="files" value="Chọn file"/>  
                           <%
                  }
                  else
                  { 
                     %>
                               <input type="button"   onclick="window.open('/Editor/aspnet/Documents.aspx','images',' width=750,height=450,left=150,top=200,toolbar=no,status=0,scrollbars=1,location=0,');" name="files" value="Chọn file"/>
                     <%
                  }
                  %>
                 <br /><br />
                 <label class="form-label"> Tóm tắt ngắn </label>
                 <%= Html.TextAreaFor(m => m.StaticIntroText, new { @class = "form-field width60" })%>
            <br /><br />
                 <label class="form-label"> Danh mục cha </label>
                <%= Html.DropDownList("CategoriesID", (MultiSelectList)ViewData["ListArticleStaticCategoryDrop"], "Select all", new { @multiple = "multiple" })%> <span style="color:Red;font-weight:bold"><%= Html.ValidationMessageFor(m => m.ArrayArticleStaticCategoryID)%></span>
                 <br /><br />
                 
                 <label class="form-label"> Nội dung </label>
                 <%= Html.TextAreaFor(m => m.StaticContent, new { @class = "form-field full" })%>
                
                 
                 <%--<label class="form-label"> Language </label>
                 <%= Html.DropDownList("LanguagesID", (SelectList)ViewData["ListLanguage"], "--Select--", new { @class = "width20" })%>
                   --%><br /><br />
                 <label class="form-label"> Ảnh </label>
                <%if (Model.Images != null)
                  {
                      string src = Model.Images;
                       
                           %>
                            
                               <img src="http://paynetvn.com/<%=Model.Images %>" id="imgname" width="150px" alt="" onclick="window.open('/Editor/aspnet/Images.aspx','images',' width=750,height=450,left=150,top=200,toolbar=no,status=0,scrollbars=1,location=0,');" />  
                           <%
                  }
                  else
                  { 
                     %>
                               <img src="/Content/images/noimage.gif" width="130px" id="imgname" alt="" onclick="window.open('/Editor/aspnet/Images.aspx','images',' width=750,height=450,left=150,top=200,toolbar=no,status=0,scrollbars=1,location=0,');" />
                     <%
                  }
                  %>
                  <%=Html.HiddenFor(m=>m.Images) %>
                  <br /><br />
                 <label class="form-label"> Kích hoạt </label>
                 <%if (Model.Active == true)
                   {
                   %>
                        <%=Html.CheckBoxFor(m=>m.Active,true) %>
                   <%
                     }
                   else
                   {
                       if ((bool)ViewData["IsAdd"])
                       {
                       %>
                        <%=Html.CheckBoxFor(m=>m.Active,true) %>
                       <%
                       }
                       else
                       { 
                       %>
                        <%=Html.CheckBoxFor(m=>m.Active) %>
                        
                       <%
                       }                   
                   } 
                    %>

                 <%=Html.TextBoxFor(m => m.StaticID, new {@Style="display:none" })%>
                <%=Html.TextBoxFor(m => m.ArrayArticleStaticCategoryID, new { @Style = "display:none" })%>

                 <p>
                <%=ViewData["Result"]%>
                </p>
                    
                 <input type="submit" value="" class="button white_input save_input "/> <!--Button Save-->
                 <a class="button white" href="javascript:history.back();"><span class="icon_text cancel"></span>Đóng</a> <!--Button Close-->
                                
                 
	        </div>
	    </div>
        <div class="clear"></div>
    
    
    <% } %>
    <script type="text/javascript">
        var selecteds = document.getElementById("ArrayArticleStaticCategoryID").value;
        var combox = document.getElementById("CategoriesID");
        var arrSeleteds = selecteds.split(",");
        for (i = 0; i < combox.options.length; i++) {
            for (j = 0; j < arrSeleteds.length; j++) {
                if (combox.options[i].value == arrSeleteds[j]) {
                    combox.options[i].selected = true;
                }
            }

        }

    </script>
</asp:Content>
